﻿
Partial Class Account_Org_Posting
    Inherits System.Web.UI.Page

    Public Sub SaveTextToFile()

        Dim temp As String
        Dim postSeparator As String
        postSeparator = "<img src='Images/post.png' width='900' height='4'/>"

        If System.IO.File.Exists(Server.MapPath("content.dat")) Then

            Dim StreamReader = New System.IO.StreamReader(Server.MapPath("content2.dat"))

            temp = StreamReader.ReadToEnd()

            StreamReader.Close()

            Dim StreamWriter = New System.IO.StreamWriter(Server.MapPath("content2.dat"))

            StreamWriter.WriteLine("<h1>" & topic.Text & "</h1>")
            StreamWriter.WriteLine(DateTime.Now.ToString("dd/MM/yyyy a't' hh:mm tt") & ", by " & postedBy.Text & "<br />")
            StreamWriter.WriteLine(postSeparator)
            StreamWriter.WriteLine(txtContent.Text & "<br /><br />")

            Response.AddHeader("Refresh", "1")

            StreamWriter.WriteLine(temp)

            StreamWriter.Close()

        Else

            Dim StreamWriter = New System.IO.StreamWriter(Server.MapPath("content2.dat"))

            StreamWriter.WriteLine("<h1>" & topic.Text & "</h1>")
            StreamWriter.WriteLine(DateTime.Now.ToString("dd/MM/yyyy a't' hh:mm tt") & ", by " & postedBy.Text & "<br />")
            StreamWriter.WriteLine(postSeparator)
            StreamWriter.WriteLine(txtContent.Text & "<br /><br />")

            StreamWriter.Close()
            Response.AddHeader("Refresh", "1")

        End If

    End Sub
End Class
